<template>
  <!-- 推荐歌单 -->
  <div id="recommend-playlist">
    <div class="split">
      <div class="dot"></div>
      <span>推荐歌单</span>
    </div>
    <!-- 推荐歌单列表 -->
    <div class="recommend-box">
      <div class="recommend-item">
        <div class="img">
          <div class="date">
            <span>{{ new Date().getDate() }}</span>
          </div>
          <div class="cover-mask"></div>
          <img src="./images/recommendBg.png" alt="cover" />
        </div>
        <div class="name">每日歌曲推荐</div>
      </div>
      <SongListCover
        class="recommend-item"
        :coverInfo="{
          id:item.id,
          count: item.playcount,
          picUrl: item.picUrl,
          name: item.name,
        }"
        v-for="item in recommendList.slice(0, 9)"
        :key="item.id"
      />
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
import SongListCover from "@/components/SongListCover";
export default {
  mounted() {
    // vuex
    this.$store.dispatch("recommendList");
  },
  computed: {
    ...mapState({
      recommendList: (state) => state.home.recommendList,
    }),
  },
  components: {
    SongListCover,
  },
};
</script>

<style lang='less'>
// 推荐列表
#recommend-playlist {
  margin-top: 30px;
  .split {
    display: flex;
    align-items: center;
    .dot {
      width: 5px;
      height: 22px;
      background: var(--themeColor1);
      display: inline-block;
      margin-right: 10px;
    }
    font-size: 20px;
    font-weight: bold;
    padding-left: 5px;
  }
  .recommend-box {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    .recommend-item {
      margin-top: 15px;
      width: 18%;
      padding: 1%;
      .img {
        width: 100%;
        position: relative;
        .date {
          width: 100%;
          height: 100%;
          position: absolute;
          display: flex;
          justify-content: center;
          align-items: center;
          cursor: pointer;
          span {
            margin-top: 10%;
            color: #fff;
            font-weight: bold;
            font-size: 22px;
          }
        }
        img {
          border-radius: 10px;
          width: 100%;
          height: 100%;
        }
        // 遮罩
        .cover-mask:hover {
          opacity: 1;
          transition: 500ms;
        }
        .cover-mask {
          opacity: 0;
          cursor: pointer;
          border-radius: 10px;
          position: absolute;
          width: 100%;
          height: 100%;
          background: rgba(0, 0, 0, 0.4);
        }
      }
    }
  }
}
</style>